# -*- coding:utf-8 -*-
from rest_framework import serializers

from Apps.UiTest.models import UiTestCaseLog
from Apps.UiTest.runTest.runUiTest import RunUiTest


class UiTestCaseLogSer(serializers.ModelSerializer):
    status_display = serializers.CharField(source='get_status_display', read_only=True)
    run_ui_test_run_flag = serializers.SerializerMethodField(read_only=True)

    class Meta:
        model = UiTestCaseLog
        fields = "__all__"
        depth = 1

    def get_run_ui_test_run_flag(self, obj):
        return "有正在执行的数据" if RunUiTest().is_run_flag else "无正在执行的数据"
